package com.huawei.updatesdk.a.a.c;

import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.io.UnsupportedEncodingException;

public class b {
    private byte[] a;
    private int b;
    private int c;

    public b() {
        this.a = null;
        this.b = WXMediaMessage.DESCRIPTION_LENGTH_LIMIT;
        this.c = 0;
        this.a = new byte[this.b];
    }

    public static String a(byte[] bArr) {
        int i = 0;
        char[] cArr = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        char[] cArr2 = new char[(bArr.length * 2)];
        int length = bArr.length;
        int i2 = 0;
        while (i < length) {
            byte b = bArr[i];
            int i3 = i2 + 1;
            cArr2[i2] = cArr[(b >>> 4) & 15];
            i2 = i3 + 1;
            cArr2[i3] = cArr[b & 15];
            i++;
        }
        return String.valueOf(cArr2);
    }

    public String a() {
        if (this.c <= 0) {
            return null;
        }
        String str;
        try {
            str = new String(this.a, 0, this.c, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            str = null;
        }
        return str;
    }

    public void a(byte[] bArr, int i) {
        if (i > 0) {
            if (this.a.length - this.c >= i) {
                System.arraycopy(bArr, 0, this.a, this.c, i);
            } else {
                Object obj = new byte[((this.a.length + i) << 1)];
                System.arraycopy(this.a, 0, obj, 0, this.c);
                System.arraycopy(bArr, 0, obj, this.c, i);
                this.a = obj;
            }
            this.c += i;
        }
    }
}
